package com.ncloud.act.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.ncloud.act.entity.AccessLog;

@Mapper
public interface AccessLogMapper{

	@Select("SELECT access_id, charge_id, acct_id, acct_balance_id, deposit_code, old_balance, money, new_balance, access_tag,"
			+ "date_format(recv_time, '%Y-%m-%d %H:%i:%s' ) as recv_time, recv_user_id,  "
			+ "cancel_tag, date_format(cancel_time, '%Y-%m-%d %H:%i:%s' ) as cancel_time, cancel_user_id, remark FROM bi_l_accesslog "
			+ "where acct_id =#{acctID} order by recv_time desc")
	@Results({
		@Result(column="access_id",property="access_id"),@Result(column="charge_id",property="charge_id"),
		@Result(column="acct_id",property="acct_id"),@Result(column="acct_balance_id",property="acct_balance_id"),
		@Result(column="deposit_code",property="deposit_code"),@Result(column="old_balance",property="old_balance"),
		@Result(column="money",property="money"),@Result(column="new_balance",property="new_balance"),
		@Result(column="access_tag",property="access_tag"),@Result(column="recv_time",property="recv_time"),
		@Result(column="recv_user_id",property="recv_user_id"),@Result(column="cancel_tag",property="cancel_tag"),
		@Result(column="cancel_time",property="cancel_time"),@Result(column="cancel_user_id",property="cancel_user_id"),
		@Result(column="remark",property="remark")})
	List<AccessLog> getAccessLogByAcctID(Long acctID);
	
	@Insert(value = "insert into bi_l_accesslog(access_id, charge_id, acct_id, acct_balance_id, deposit_code, old_balance, money, new_balance, access_tag, recv_time, recv_user_id, cancel_tag, cancel_user_id, remark) "
			+ "values(#{access_id},#{charge_id},#{acct_id},#{acct_balance_id},#{deposit_code},#{old_balance},#{money},#{new_balance},#{access_tag},#{recv_time},#{recv_user_id},#{cancel_tag},#{cancel_user_id},#{remark})")
    public int insertAccessLog(AccessLog accessLog);
}
